﻿<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8" import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<%@ include file="taglibs.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/easyui/jquery.min.js"></script>
<link rel="stylesheet" href="${ctx}/static/css/style.css" type="text/css" />
</head>
<body>
	<div class="header">
        <div class="headertop">
          <ul>
           <!-- <li class="indexlogo"><img  src="${ctx}/static/images/system/indexlogo.png"/></li>
           <li class="indexlogob"></li> -->
           <li class="indexlogotitle">${system.sysName}</li>
           </ul>
        </div>
        <div class="headermenu">
           <ul id=menuListMore>
           	   <c:forEach items="${menuList}" var="topMenu" varStatus="st">
           	   		<li tag="${st.index}" >
		               <a href="<c:choose><c:when test="${empty topMenu.menuHref}">javascript:void(0);</c:when><c:otherwise>${ctx }${topMenu.menuHref}</c:otherwise></c:choose>"  
		               	  target="MainMenu"
		               	  onclick="showLandMenu('landMenu${st.index}')" 
		                  onfocus="this.blur();">
		               <img class="icoimg" src="${ctx }${topMenu.menuIconPath}"/>${topMenu.menuName}
		               </a>
	                </li>
           	   </c:forEach>
           </ul>
        </div>
    </div>  
    <div class="headernav">
    	<c:forEach items="${menuList}" var="topMenu" varStatus="st">
    		<div id="landMenu${st.index }" class="navchildmenu">
	          <ul id="menuList"> 
	          	<c:forEach items="${topMenu.children}" var="landMenu" varStatus="st2">
	          		<li tag="landMenu${st.index}_leftMenu${st2.index}">
						<a target='MainMenu'
						href="<c:choose><c:when test="${empty landMenu.menuHref}">javascript:void(0);</c:when><c:otherwise>${ctx }${landMenu.menuHref}</c:otherwise></c:choose>" 
                        onfocus="this.blur();" >${landMenu.menuName}</a>
					</li>
	          	</c:forEach>
	          </ul>
	        </div>
    	</c:forEach>
    </div>
    
    <!-- 左侧三级菜单 -->
	<div class="box3">
		<c:forEach items="${menuList}" var="topMenu" varStatus="st">
			<c:forEach items="${topMenu.children}" var="landMenu" varStatus="st2">
				<c:forEach items="${landMenu.children }" var="leftMenu" varStatus="st3">
					<div id="landMenu${st.index }_leftMenu${st2.index}_${st3.index}" style="display: none;">
						<dl >
							<dd>
								<div class="title">
									<a 
						    			href="<c:choose><c:when test="${empty leftMenu.menuHref}">javascript:void(0);</c:when><c:otherwise>${ctx }${leftMenu.menuHref}</c:otherwise></c:choose>" 
						    			target="MainMenu">
						    			<span><img src="${ctx}/static/images/system/leftico01.png" /></span>${leftMenu.menuName}
					    			</a>
						    	</div>
						    	
						    	<ul class="menuson">
						    		<c:forEach items="${leftMenu.children}" var="leftChildrenMenu">
						    			<li><cite></cite><a 
						    			href="<c:choose><c:when test="${empty leftChildrenMenu.menuHref}">javascript:void(0);</c:when><c:otherwise>${ctx }${leftChildrenMenu.menuHref}</c:otherwise></c:choose>" 
						    			target="MainMenu">${leftChildrenMenu.menuName}</a><i></i></li>
						    		</c:forEach>
						        </ul>
							</dd>
			    		</dl>
	    			</div>
				</c:forEach>			
			</c:forEach>	    
		</c:forEach>
	</div>
</body>

<script type="text/javascript">
	$(function() {
		$("#menuList li").click(function() {
			var id = $(this).attr("tag");
			var html = "";
			$('div[id^='+id+']').each(function(){
				html+=$(this).html();
			});
			parent.LeftMenu.navMain.innerHTML = "";
			parent.LeftMenu.navMain.innerHTML = html;
			parent.LeftMenu.menuClick();
		});
		
		//登录成功后的默认显示首页
		var tag_first=$("#menuListMore li a")[0];
		tag_first.click();

		//获取服务器时间
		showTime();
		getAlertInfo();
		setInterval("showTime()", "1000");
		//setInterval("getAlertInfo()", "1000");
	});
	
	function getAlertInfo(){
		$.post('${ctx}/scada/alertData/list', function(
				data) {
			var str = "";
			$.each(data.rows,function(index,item){
				str += "<span>"+item.INFRAS_NAME+"</span>&nbsp";
				str += "<span>"+item.METER_NAME+"("+item.METER_CODE+")"+"</span>&nbsp";
				str += "<span>"+item.PARAM_NAME+"</span>&nbsp";
				str += "<span>"+item.LEVEL_NAME+"</span>&nbsp";
				str += "<span>"+item.DATA_VALUE+item.PARAM_UNIT+"</span>&nbsp";
				str += "<span>"+item.MORE_THEN+item.PARAM_UNIT+"</span>&nbsp&nbsp&nbsp";
			});
			$("#alertInfo").html(str);
		}, 'json');
	}
</script>

<script type="text/javascript"> 
	//创建XMLHTTP对象
	var xmlHttp=null;
	try{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e) { 
	    try { 
	    	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	      }catch(e2){
	    	  xmlHttp=null;
	      }
	}
	if (xmlHttp==null){
		xmlHttp=new XMLHttpRequest();
	}
	//从哪个服务器上获取时间
	xmlHttp.open("HEAD","${ctx}",false);  
	//连接服务器
	xmlHttp.send();                                      
	//获取标头中的时间
	var offset = Date.parse(xmlHttp.getResponseHeader("Date"));
	//获取本地时间与服务器时间的间隔
	offset -= (new Date).getTime();       
	//显示时间的方法
	function showTime(){
		//获取当前时间                                     
		 var d = new Date;                                       
		//通过服务器和本地的时间间隔获取当前服务器时间
		 d.setTime(d.getTime()+offset);
		//显示服务器时间
		$("#showTime").html(formatCSTDate(d,"yyyy-MM-dd hh:mm:ss"));
	}
	//格式化CST日期的字串
    function formatCSTDate(strDate,format){
     	 return formatDate(new Date(strDate),format);
    }
    //格式化日期,
    function formatDate(date,format){
        var paddNum = function(num){
        num += "";
        return num.replace(/^(\d)$/,"0$1");
      }
      //指定格式字符
      var cfg = {
         yyyy : date.getFullYear() //年 : 4位
        ,yy : date.getFullYear().toString().substring(2)//年 : 2位
        ,M  : date.getMonth() + 1  //月 : 如果1位的时候不补0
        ,MM : paddNum(date.getMonth() + 1) //月 : 如果1位的时候补0
        ,d  : date.getDate()   //日 : 如果1位的时候不补0
        ,dd : paddNum(date.getDate())//日 : 如果1位的时候补0
        ,hh : paddNum(date.getHours())  //时  如果1位的时候补0
        ,mm : paddNum(date.getMinutes()) //分 如果1位的时候补0
        ,ss : paddNum(date.getSeconds()) //秒 如果1位的时候补0
      };
      format || (format = "yyyy-MM-dd hh:mm:ss");
      return format.replace(/([a-z])(\1)*/ig,function(m){return cfg[m];});
    } 
    
    //点击顶级菜单 ---> 顶部二级菜单
	function showLandMenu(id){
	  $(".headernav div").hide();
	  $("#"+id+"").show();
	}
    
	//注销用户
	function logout() {
	    var url = '${ctx}/logout';
	    window.parent.location = url;
	}
</script>


</html>